import xlrd

# 打开文件
xlsx = xlrd.open_workbook("O:\Lxy_Py\py/text.xls")
# 获取到指定的标签页
table = xlsx.sheet_by_index(0)
# 获取到表格有多少行
nrows = table.nrows
# print(f"nrows = {nrows}")
# 进行循环统计操作
total = 0
count = 0
for i in range(1,nrows):
    # 拿到当前同学的班级id
    # print("=============================")
    # print(table.cell_value(i,1))
    # print(table.cell_value(i,0))
    # print(table.cell_value(i,2))
    classId = table.cell_value(i,1)
    if classId==12:
        total+=table.cell_value(i,2)
        count+=1
print(f"平均分: {total/count}")